package tabdulin.sms;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

import tabdulin.util.FileDownloader;
import static org.junit.Assert.*;

public class FileDownloaderTest {
	@Test
	public void testDownload() {
		try {
			long size = FileDownloader.download("http://sms.megafonmoscow.ru/captcha/1594826", "captcha.jpeg");
			File captcha = new File("captcha.jpeg");
			assertTrue(captcha.exists());
			assertTrue(size > 0);
			if (!captcha.delete()) {
				fail("Captcha was not deleted");
			}
		} catch (IOException e) {
			fail("Exception was caught");
			e.printStackTrace();
		}
	}
}
